<?php
date_default_timezone_set('GMT');
error_reporting(E_ALL|E_STRICT);
//date_default_timezone_set('Europe/London');
set_include_path('.' . PATH_SEPARATOR . './library/'
	 . PATH_SEPARATOR . './application/models'
	 . PATH_SEPARATOR . get_include_path());
	 

//aloha
include "Zend/Loader.php";
echo 'aloha';
Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Registry');
Zend_Loader::loadClass('Smarty_View');
Zend_Loader::loadClass('Zend_Config_Ini');
Zend_Loader::loadClass('Zend_Db');
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Auth');
Zend_Loader::loadClass('Zend_Acl');
Zend_Loader::loadClass('Zend_Debug');
Zend_Loader::loadClass('Zend_Db_Adapter_Pdo_Mysql');
//khai bao phuong thuc getInstance de nhan cac gia tri moi
$registry = Zend_Registry::getInstance();
// load configuration
$config = new Zend_Config_Ini('application/config.ini', 'sub_general');
$registry->set('config', $config);

// setup database
//Su dung phuong thuc tinh factory voi 2 tham so de cau hinh ket noi toi co so du lieu
/*
 * Tham so 1: cau hinh Adapter - loai co so du lieu tuong thich de ket noi (Pdo_Mysql)
 * Tham so 2: cau hinh config  -1 mang gom cac thong tin ket noi 
 * Su dung Zend_Db::factory de thay the cho viec goi cac Zend_Defaul_Adapter_Pdo_Mysql
 * */
//$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
//Zend_Db_Table::setDefaultAdapter($db);
//Neu khong co the su dung Class Zend_Db_Adapter_Pdo_Mysql de nap cau hinh config cua file config.ini
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
	'host' => 'localhost',
	'username' => 'root',
	'password' => 'vertrigo',
	'dbname' => 'zftutorial'
	));
Zend_Db_Table::setDefaultAdapter($db);
$registry->set('db', $db);
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('application/controllers');
// run!
$frontController->dispatch();
